package cn.ac.sec.liquid.dic;

import cn.ac.sec.liquid.common.model.Dic;

import com.jfinal.core.Controller;

public class DicController extends Controller {
	public void index() {
		setAttr("dicList", Dic.dao.find("select * from dic"));
		render("dic.html");
	}
	
	public void add() {
		setAttr("dicType", Dic.DicType.values());
	}
	
//	@Before(QuestionValidator.class)
	public void save() {
		Dic dic = getModel(Dic.class);
		dic.save();
		redirect("/dic");
	}
	
	public void edit() {
		setAttr("dicType", Dic.DicType.values());
		setAttr("dic", Dic.dao.findById(getParaToInt()));
	}
	
	public void update() {
		Dic dic = getModel(Dic.class);
		dic.update();
		redirect("/dic");
	}
	
	public void delete() {
		Dic.dao.deleteById(getParaToInt());
		redirect("/dic");
	}
	
	public void batchDelete(){
		String ids[] = getParaValues("ids");
		for(String id : ids){
			Dic.dao.deleteById(Integer.valueOf(id));
		}
		redirect("/dic");
	}
}


